package com.ideal.gpt.app.local;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.lzwork.utility.file.LineContent;
import com.lzwork.utility.str.StrUtility;

/**
 * @author LiZheng
 * @date 2024年1月30日 11:31:13
 */

public class CutLine
{
	public static void cutLine(File input, File output, String prefix)
	{
		List<String> lines = LineContent.loadFile(input);

		List<String> outLines = new ArrayList<>();

		for (String line : lines)
		{
			int index = line.indexOf(prefix);
			if (index == 0)
				outLines.add(line);
			else if (index > 0)
			{
				String cutString = line.substring(index);
				outLines.add(cutString);
			}
		}
		
		String outString = StrUtility.combineString(outLines, "\n\r\n\r");

		LineContent.saveFile(output, outString);
	}

	public static void main(String[] args)
	{
		File input = new File("F:/Downloads/111.txt");
		File output = new File("F:/Downloads/222.txt");
		
		cutLine(input, output, "file://");
	}
}
